#include <stdio.h>
#include <stdlib.h>

/**
 * Note: The returned array must be malloced, assume caller calls free().
 */
int* twoSum(int* nums, int numsSize, int target, int* returnSize) {
    int *ret = malloc(sizeof(int)*2);
    for(int i = 0; i < numsSize - 1; i++)
    {
        for(int j = i + 1; j < numsSize; j++)
        {
            if(nums[i] + nums[j] == target)
            {
                ret[0] = i;
                ret[1] = j;
                *returnSize = 2;
                return ret;
            }            
        }
    }
    return NULL;
}

int main(void)
{
    int nums[] = {2, 7, 11, 15};
    int numsSize = sizeof(nums)/sizeof(nums[0]);
    int target = 9;
    int returnSize = 0;
    int* result= twoSum(nums, numsSize, target, &returnSize);

    for(int i = 0; i < returnSize; i++)
    {
        printf("%d ",*(result+i));
    }
    return 0;
}
